home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6081 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: access1.digex.net!not-for-mail
  2. From: ell@access1.digex.net (Ell)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: cin.get(string) problem
  5. Date: 11 Feb 1996 22:12:46 GMT
  6. Organization: The Universe
  7. Message-ID: <4flpku$r7e@news4.digex.net>
  8. References: <4fk7e5$j9h@cloner3.netcom.com>
  9. NNTP-Posting-Host: access1.digex.net
  10. X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
  11.  
  12. Manuel Hernandez (ManuelHe@ix.netcom.com) wrote:
  13. : greinerk@ix.netcom.com (Kurt W. Greiner) writes:
  14. : > Hi all,
  15. : >         i was trying some really simple io for a program that just gets 
  16. : > values, here is a sample of code
  17. : > 
  18. : > #include <iostream.h>
  19. : > 
  20. : > void main(void)
  21. : > {
  22. : >         char string[80];
  23. : >         cin.get(string,sizeof(string));
  24. : >         cin.get(string,sizeof(string));
  25. : > }
  26. : > 
  27. : > ok, say i want to read in a name on the first cin, i type in "john smith" and 
  28. : > the prompt, john gets thrown in to the first and smith the second, i do not 
  29. : > even get prompted for the second cin. it does not happen if i type in a string 
  30. : > with out spaces. i am using borland c++ 2.0, am i doing something wrong or is 
  31. : > there an other way of doing this other than gets(string)?
  32. : >...
  33.  
  34. Right, I find that getline() works better than get() in most cases.
  35.  
  36. Elliott
  37.